/**
 * 飞机基类
 */
var UtilGameObject = require('./../../../../FrameWork/Utils/UtilGameObject');
var BaseBody = require('./../BaseBody');
var EnemyBody = require('./../Enum/EnumBody');
var EnumPlane = require('./../Enum/EnumPlane');
module.exports = cc.Class(
{
    extends: BaseBody,

    properties:
    {
        spIcon:
        {
            default: null,
            type: cc.Sprite,
            displayName: '飞机icon'
        },
        prefabBomb:
        {
            default: null,
            type: cc.Prefab,
            displayName: '爆炸特效'
        },
        enumPlane:
        {
            default: EnumPlane.NONE,
            type: EnumPlane,
            displayName: '飞机类型',
            visible: false
        }
    },
    onLoad()
    {
        this._super();
        this.setEnumBody(EnemyBody.PLANE);
    },
    onCollisionEnter: function(other)
    {
        var body = this._super(other);
        if (null == body)
        {
            cc.error('发现不明物品请处理');
            return null;
        }
        return body;
    },
    /***飞机换装  
     * _spriteFrame:飞机图片
     */
    refreshPlaneIcon: function(_spriteFrame)
    {
        if (_spriteFrame == null)
        {
            cc.errror('refreshPlaneIcon ： _spriteFrame is null ');
            return;
        }
        if (spIcon == null)
        {
            cc.errror('refreshPlaneIcon ： spIcon is null ');
            return;
        }
        this.spIcon.sprtiteFrame = _spriteFrame;
    },
    /**
     * 播放爆炸特效 
     */
    playBomb(other)
    {
        var obj = UtilGameObject.createAddparentByPrefabs(this.prefabBomb, this.node.parent);

        var otherNode = other.node;
        obj.x = otherNode.x;
        obj.y = otherNode.y;
        this.playAudio();
    },

    setEnumPlane(_enumPlane)
    {
        this.enumPlane = _enumPlane;
    },
    getEnumPlane()
    {
        return this.enumPlane;
    },

});